<?php

$id=$_POST['id'];
$title=$_POST['title'];
$web=$_POST['status'];
$link=$_POST['link'];
$author=$_POST['author'];
$publishtime=date('Y-m-d h:i:s',time());
$content=$_POST['content'];
$title1=$_POST['title1'];
$web1=$_POST['web1'];
$author1=$_POST['author1'];
$connect=mysql_connect("localhost","root","192510");

mysql_select_db("news",$connect);

//不可编辑不能得到值
$sql="select * from news where id={$id}";
$result=mysql_query($sql);
$row=mysql_fetch_assoc($result);
$web2=$row['web'];
$link2=$row['link'];


$nmd5=$title.$author;

if($id==null){
	if($title!=null){
		$sql="insert into news(title,web,author,publishtime,content,link,nmd5) value('$title',5,'$author','$publishtime','$content','$link','$nmd5')";
        mysql_query($sql);
	    echo "<script>location='select_new.php?title=$title1&&web=$web1&&author=$author1';</script>";
	}else{
		
		 echo "<script>location='insert_new.php';</script>";
	}
	
}else{
	$sql="update news set title='$title',web='$web2',author='$author',publishtime='$publishtime',content='$content',link='$link2' where id='$id'";
	echo $sql;
	mysql_query($sql);
	echo "<script>location='select_new.php?title=$title1&&web=$web1&&author=$author1';</script>";
}

?>
